package com.evry.main;

import java.util.List;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.evry.domain.collateralitem.CollateralItem;
import com.evry.domain.collateralitem.Mortgagor;
import com.evry.service.CollateralItemManager;

public class App {
	public static void main(String[] args) {
		//changed from classpathxmlapplicationcontext in order to set active profiles. Still doesn't work	    
	    AnnotationConfigApplicationContext  appContext = new AnnotationConfigApplicationContext();
	    appContext.getEnvironment().setActiveProfiles("production");
	    appContext.scan("com.evry.config");
	    appContext.refresh();
		CollateralItemManager collateralItemManager = (CollateralItemManager)appContext.getBean("collateralItemManager");
		List<CollateralItem> collateralItems = collateralItemManager.getAllCollateralItems();
		for (CollateralItem collateralItem : collateralItems){
			System.out.println(collateralItem.getDesignation());
			System.out.println(collateralItem.getDescription());
			for (Mortgagor mortgagor : collateralItem.getMortgagors()){
				System.out.println("Objekt " + collateralItem.getObjectNumber() + " har en mortgagor med �garandel: " + mortgagor.getOwnersShareNumerator() + "/" + mortgagor.getOwnersShareDenominator());
			}
		}
	}
}
